export const copyText = function(text) {
    const textarea = document.createElement('textarea');
    const currentFocus = document.activeElement;
    document.body.appendChild(textarea)
    textarea.value = text;
    textarea.focus();
    if (textarea.setSelectionRange) {
        textarea.setSelectionRange(0, textarea.value.length);
    } else {
        textarea.select();
    }
    let flag;
    try {
        flag = document.execCommand('copy');
    } catch (error) {
        flag = false;
    }
    document.body.removeChild(textarea);
    currentFocus.focus();
    return flag;
}
